from rest_framework.viewsets import ModelViewSet
from rest_framework.generics import ListAPIView
from goods.models import SPUSpecification, SpecificationOption
from meiduo_admin.serializers.specification_serializers import SPUSpecificationSerializer, SpecificationOptionSerializer
from meiduo_admin.utils import MyPagination


class SpecsView(ModelViewSet):
    """ 规格表数据 增删改查 """

    queryset = SPUSpecification.objects.all().order_by("id")
    serializer_class = SPUSpecificationSerializer
    pagination_class = MyPagination


class OptionsView(ModelViewSet):
    """ 规格选项表数据 增删改查 """

    queryset = SpecificationOption.objects.all().order_by("id")
    serializer_class = SpecificationOptionSerializer
    pagination_class = MyPagination


class OptionSimple(ListAPIView):
    """ 获取商品规格名称 """

    queryset = SPUSpecification.objects.all()
    serializer_class = SPUSpecificationSerializer
    pagination_class = None
